# This code is part of the MWP System
# Copyright (c) 2012 Benjamin Lubin (blubin@bu.com) 
# Published under and subject to the GPLv2 license available at http://www.gnu.org/licenses/gpl-2.0.html

'''
Created on Dec 14, 2012
@author: blubin
'''

from frontend.roleApplication import RoleApplication;
from frontend.form import Type;

class CustomerApplication(RoleApplication):
    """ The Customer User Interface """

    def __init__(self):
        super(CustomerApplication, self).__init__("PuppyService3", "Customer");
        self.register_source_step("CallRequest", self.call_request_form_creator, form_handler=self.collect_payment_form_handler);

    def call_request_form_creator(self, stepname, form):
        form.add_static_label('Welcome to Bad to the Bone Puppy Rentals! Our standard rate is $100 per hour per puppy.')
        form.add_static_label('To schedule an appointment with our furry friends, fill out the form below:')
        form.add_field(Type.SHORTSTRING, "FirstName", labeltext="First Name");
        form.add_field(Type.SHORTSTRING, "LastName", labeltext="Last Name");
        form.add_field(Type.SHORTSTRING, "Location", labeltext="Location");
        form.add_field(Type.DATE, "DesiredTime", labeltext="Desired Date");
        form.add_field(Type.FLOAT, "Duration", labeltext="Duration (in hrs)");
        form.add_field(Type.SHORTSTRING, "StartTime", labeltext="Start Time");
        form.add_field(Type.INTEGER, "NumberDogs", labeltext="Number of Puppies");
        
    def collect_payment_form_handler(self, stepname, data, task):
        #data["amount"]=task.get_int_field("numberdogs")*task.get_float_field("duration")*100
        data["amount"] = data["numberdogs"] * data["duration"] * 100
        RoleApplication.default_form_handler(self, stepname, data, task)

if __name__ == '__main__':
    app = CustomerApplication();
    app.MainLoop();